# import required packages
import json
import os
import cv2
from IPython.display import Image, Video
import pandas as pd
print(os.getcwd())
C:\Users\Alphons\OneDrive\Documents\Automated-Air-Liquid-Interface-Cell-Culture-Analysis-Using-Deep-Optical-Flow\examples\image_series_1\(tif) 191018_HNA-ALI_d14.nd2 - 191018_HNA-ALI_d14.nd2 (series 03)0000_etc
# Load metadata
with open('metadata.json') as f:
metadata = json.load(f)
print(metadata['type'])
.tif
print(metadata['analysis_timestamp'])
08 April 2021, 12:18:22
print(json.dumps(metadata, sort_keys=True, indent=4))
{
"analysis_timestamp": "08 April 2021, 12:18:22",
"calibration_um": 0.31302569743655434,
"dir": "C:\\Users\\Alphons\\OneDrive\\Documents\\Automated-Air-Liquid-Interface-Cell-Culture-Analysis-Using-Deep-Optical-Flow\\examples\\image_series_1",
"type": ".tif"
}
df = pd.read_csv('mag_stats.csv', sep=',')
print(df)
frame min (um) max (um) mean (um) std (um) var (um) 0 0 0.002189 5.659570 2.134026 0.769607 0.592295 1 1 0.007036 6.528444 2.085508 0.828145 0.685824 2 2 0.005678 5.720573 2.050779 0.796154 0.633862 3 3 0.002304 7.910612 1.978159 0.765331 0.585732 4 4 0.001809 6.771280 1.893380 0.784511 0.615457 5 5 0.001108 6.631174 1.770301 0.668799 0.447292 6 6 0.000766 5.486326 1.736731 0.663099 0.439700 7 7 0.007854 7.604922 1.720270 0.686412 0.471162 8 8 0.001544 5.223944 1.766581 0.742917 0.551926 9 9 0.003467 5.256399 1.726751 0.753714 0.568084 10 10 0.005359 7.906752 1.759532 0.706948 0.499775 11 11 0.001898 6.605864 1.763779 0.755759 0.571172 12 12 0.002250 6.330100 1.711699 0.713090 0.508497 13 13 0.001300 8.591791 1.684315 0.720923 0.519731 14 14 0.001470 11.625805 1.684152 0.741490 0.549808 15 15 0.000908 5.909985 1.642674 0.751054 0.564083 16 16 0.002081 6.830723 1.694560 0.724541 0.524959 17 17 0.001529 6.277352 1.709413 0.741429 0.549717 18 18 0.000930 5.813552 1.695623 0.720815 0.519574
df = pd.read_csv('dirn_stats.csv', sep=',')
print(df)
frame min (deg) max (deg) mean (deg) std (deg) var (deg) 0 0 0.000291 359.999969 126.017021 124.564008 15516.192018 1 1 0.000028 359.999603 161.746219 135.633649 18396.486804 2 2 0.000493 359.999908 161.909639 131.181341 17208.544188 3 3 0.000007 359.999939 169.133588 133.438504 17805.834264 4 4 0.000105 360.000000 181.327410 130.671843 17075.130625 5 5 0.000625 359.999939 186.161654 121.755672 14824.443715 6 6 0.000034 359.999542 180.747084 117.334445 13767.371877 7 7 0.000129 359.999878 183.374644 119.924125 14381.795800 8 8 0.000388 359.999908 177.643768 123.005852 15130.439508 9 9 0.000008 360.000000 186.818240 118.580904 14061.430882 10 10 0.000012 359.999390 170.768012 118.375267 14012.703734 11 11 0.000349 359.999878 187.630205 118.845236 14124.190120 12 12 0.000058 359.999725 180.344546 117.253174 13748.306783 13 13 0.000041 359.999908 168.804033 114.881794 13197.826541 14 14 0.000123 359.999695 171.097494 117.221801 13740.950567 15 15 0.000390 359.999969 170.326365 113.067118 12784.173157 16 16 0.000809 359.999664 177.686857 117.532094 13813.793091 17 17 0.000206 359.999969 166.113347 114.204230 13042.606063 18 18 0.000655 359.998566 180.108439 112.246061 12599.178306
# video resizing function
def video_reshp(vid_path, set_wdh=None):
cap = cv2.VideoCapture(vid_path)
hgt, wdh, _ = cap.read()[1].shape
dsp_wdh = set_wdh if set_wdh is not None else wdh
dsp_hgt = dsp_wdh * (hgt / wdh) if wdh is not None else hgt
return dsp_wdh, dsp_hgt
vid_path = 'Combined Images/Combined.mp4v'
dsp_wdh, dsp_hgt = video_reshp(vid_path, 1280)
Video(vid_path, embed=True, width=dsp_wdh, height=dsp_hgt, html_attributes='controls loop')
a) The direction of motion at any position within RAINBOW generated optical flow images is measured clockwise from the initial horizontal position of a unit circle (left) and is shown using hue values (right).
b) The magnitude of motion at any position within RAINBOW generated optical flow images is shown using saturation values. For instance, high saturation corresponds to high magnitude of motion and low saturation corresponds to low magnitude of motion. For instance, high saturation (100%) corresponds to high magnitude of motion and low saturation (25%) corresponds to low magnitude of motion.
vid_path = 'Heatmaps/heatmap.mp4v'
dsp_wdh, dsp_hgt = video_reshp(vid_path, 640)
Video(vid_path, embed=True, width=dsp_wdh, height=dsp_hgt, html_attributes='controls loop')
Visualization of motion magnitiude using heatmap with hot colour mapping.
vid_path = 'Quiver Plots/quiver_plot.mp4v'
dsp_wdh, dsp_hgt = video_reshp(vid_path, 640)
Video(vid_path, embed=True, width=dsp_wdh, height=dsp_hgt, html_attributes='controls loop')
Visualisation of optical flow using quiver plots containing vector arrows.